package com.mapper;

import com.entity.School;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SchoolMapper {
    // 查询所有学校信息
    @Select("select * from school;")
    List<School> selectAllSchools();

    // schoolName 查询学校信息
    @Select("select * from school where schoolName like '%${schoolName}%';")
    List<School> selectSchoolBySchoolName(String schoolName);

    // id 查询学校信息
    @Select("select * from school where schoolId = #{schoolId};")
    School selectSchoolBySchoolId(int schoolId);

    // id 删除学校信息
    @Delete("delete from school where schoolId = #{schoolId};")
    int deleteSchoolBySchoolId(int schoolId);

    // 新增学校信息
    @Insert("insert into school (schoolName, schoolAddress, schoolPhone) VALUES (#{schoolName},#{schoolAddress},#{schoolPhone});")
    int insertSchool(School school);

    // 修改学校信息
    @Update("update school set schoolName = #{schoolName},schoolAddress = #{schoolAddress},schoolPhone = #{schoolPhone} where schoolId = #{schoolId};")
    int updateSchool(School school);
}
